package mx.com.crowdgine.util.math;

final public class MathCommons{
	
	/**
     * Clamp a value between a min and a max value
     * 
     * @param value The value to clamp
     * @param min The minimum possible value
     * @param max The maximum possible value
     * @return The clamped value between min and max.
     */
    public static float clamp(float value, float min, float max) {
    	if(value < min){
    		return min;
    	}else if (value > max){
    		return max;
    	}
    	return value;
    }
    
    /**
     * Clamp a value between a min and a max value
     * 
     * @param value The value to clamp
     * @param min The minimum possible value
     * @param max The maximum possible value
     * @return The clamped value between min and max.
     */
    public static int clamp(int value, int min, int max) {
    	if(value < min){
    		return min;
    	}else if (value > max){
    		return max;
    	}
    	return value;
    }
    
}
